from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

db = SQLAlchemy()


class HotSearch(db.Model):
    __tablename__ = 'hot_searches'

    id = db.Column(db.Integer, primary_key=True)
    note = db.Column(db.String(255), nullable=False)
    num = db.Column(db.Integer, nullable=False)
    label = db.Column(db.String(10))
    flag = db.Column(db.String(20))
    create_time = db.Column(db.DateTime, default=datetime.now)

    def to_dict(self):
        return {
            'Note': self.note,
            'Num': self.num,
            'Label': self.label,
            'Flag': self.flag
        }